$(function () {
    // 获取导航
    $.ajax({
        type: 'post',
        url: $.webConfig.apiUrl + 'top/gettop',
        dataType: 'json',
        success: function (data) {
            if (data['return_code'] == 1) {
                //获取模板
                var jsRenderTplNav = $.templates('#nav-specCard');
                //末班与数据结合
                var finalTplNav = jsRenderTplNav(data);
                $('#nav-box').html(finalTplNav);
                
                var lmid = $.getUrlParam('lmid');

                $("#nav-box li").removeClass('active');
                $("#nav-box li[lmid=" + lmid + "]").addClass('active');
            }
        },
        error: function (err) {
            console.log(err);
        }
    });

    // 获取footer信息
    $.ajax({
        type: 'post',
        url: $.webConfig.apiUrl + 'config/getconfig',
        dataType: 'json',
        success: function (data) {
            console.log(data);
            if (data['return_code'] == 1) {

                var obj = {};
                $.each(data['return_body'], function (key, val) {
                    if (val['title'] == '版权所有') {
                        obj['bqsy'] = val['content'];
                    } else if (val['title'] == '地址') {
                        obj['dz'] = val['content'];
                    } else if (val['title'] == '电话') {
                        obj['dh'] = val['content'];
                    } else if (val['title'] == '报警电话') {
                        obj['bjdh'] = val['content'];
                    } else if (val['title'] == '备案号') {
                        obj['bah'] = val['content'];
                    }else if (val['title'] == '负责人') {
                        obj['fzr'] = val['content'];
                    }else if (val['title'] == '维护人') {
                        obj['whr'] = val['content'];
                    }
                });

                //获取模板
                var jsRenderTpl = $.templates('#footer-specCard');
                //末班与数据结合
                var finalTpl = jsRenderTpl(obj);
                $('#footer-box').html(finalTpl);
            }
        },
        error: function (err) {
            console.log(err);
        }
    });

});